package tgc.edu.yzy.custom;

import java.io.IOException;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;

import com.forte.qqrobot.beans.messages.msgget.GroupMsg;
import com.forte.qqrobot.sender.MsgSender;
import com.forte.qqrobot.utils.CQCodeUtil;

import tgc.edu.yzy.cocApi.custom.TxtCoc;
import tgc.edu.yzy.cocApi.entity.ClansClanTag.ClansClanTag;

public class CocCustomImage{
	/****
	 * 暂时废弃
	 * 生成部落 图片
	 * @param clan
	 * @param msgsender 
	 * @param cqCodeUtil 
	 * @param msg 
	 */
	public static void ClanImage(GroupMsg msg, CQCodeUtil cqCodeUtil, MsgSender msgsender) {
		
		try {
			String get = TxtCoc.getCoc("部落299UPVLPG");
			String post = get.substring(19, get.length());
			ObjectMapper mapper = new ObjectMapper();
			ClansClanTag clan = mapper.readValue(post,new TypeReference<ClansClanTag>() { });
			/****
			 * 
			 */
			//生成部落图片
			boolean main = CocImageClan.main(clan);
			if(main) {
				msgsender.SENDER.sendGroupMsg(msg.getGroup(), cqCodeUtil.getCQCode_At(msg.getQQ())+"[CQ:image,file="+clan.getBadgeUrls().getSmall()+"][CQ:image,file=部落"+clan.getTag()+".png]");
			}else {
				String userClanGo = CocCustom.UserClanGo(clan);
				userClanGo = " 图片生成失败！\n\n"+userClanGo;
				msgsender.SENDER.sendGroupMsg(msg.getGroup(), cqCodeUtil.getCQCode_At(msg.getQQ())+userClanGo);
			}
			//CocCustomImage.ClanImage(clan,msg,cqCodeUtil,msgsender);
			//msgsender.SENDER.sendPrivateMsg("936642284", "[CQ:image,file=emage.jpg] ");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

	


}
